package taller2.controller.listeners.GraphCreator;

import javax.swing.JComboBox;

import taller2.controller.listeners.MouseHandler;
import taller2.controller.modes.AddCapacityAndUseMode;
import taller2.controller.modes.AddMode;
import taller2.controller.modes.AddTagMode;
import taller2.controller.modes.BeginNodeMode;
import taller2.controller.modes.ConnectMode;
import taller2.controller.modes.DeleteAllMode;
import taller2.controller.modes.DeleteConnectionsMode;
import taller2.controller.modes.DeleteNodeMode;
import taller2.controller.modes.EndNodeMode;
import taller2.controller.modes.MoveMode;
import taller2.controller.modes.RandomGraphMode;
import taller2.interfaces.AlgorithmApplicator;
import taller2.interfaces.Graph;
import taller2.utils.Constants;
import taller2.view.draws.DrawingArea;

public class FordFulkersonCreatorMenuListener extends GraphCreatorMenuListener{

	public FordFulkersonCreatorMenuListener(DrawingArea area, Graph graph,
			AlgorithmApplicator algorithmApplicator) {
		super(area, graph, algorithmApplicator);
		
		this.setAvailableOptions(Constants.availableFordFulkersonOptions);
	}

	// handles the event if it is a menu change
	@Override
	protected void handleMenu(MouseHandler handler,JComboBox<?> menu){
        String selected = (String) menu.getSelectedItem();
    
		if(selected.equals(getAvailableOptions()[0])){
			handler.ChangeMode(new MoveMode());
		}else if(selected.equals(getAvailableOptions()[1])){
			handler.ChangeMode(new AddMode(graph));
		}else if(selected.equals(getAvailableOptions()[2])){
			handler.ChangeMode(new AddTagMode());
		}else if(selected.equals(getAvailableOptions()[3])){
				handler.ChangeMode(new ConnectMode(graph));
		}else if(selected.equals(getAvailableOptions()[4])){
			handler.ChangeMode(new RandomGraphMode(graph));	
		}else if(selected.equals(getAvailableOptions()[5])){
				handler.ChangeMode(new DeleteNodeMode(graph));
		}else if(selected.equals(getAvailableOptions()[6])){
				handler.ChangeMode(new DeleteConnectionsMode(graph));
		}else if(selected.equals(getAvailableOptions()[7])){
				handler.ChangeMode(new DeleteAllMode(graph));
		}else if(selected.equals(getAvailableOptions()[8])){
			handler.ChangeMode(new BeginNodeMode(algorithmApplicator, graph));
		}else if(selected.equals(getAvailableOptions()[9])){
			handler.ChangeMode(new EndNodeMode(algorithmApplicator, graph));
		}else if(selected.equals(getAvailableOptions()[10])){
			handler.ChangeMode(new AddCapacityAndUseMode(graph));
		}
	}
	
}